import { Result } from "antd-mobile";
import React from "react";
import {
  // BrowserRouter as Router,

  Router,
  Redirect,
  Route,
  Switch,
} from "react-router-dom";
import Article from "./pages/Article";
import NotFound from "./pages/NotFound/index";
import Chat from "./pages/Profile/Chat";
import ProfileEdit from "./pages/Profile/Edit";
import ProfileFeedback from "./pages/Profile/Feedback";
import Search from "./pages/Search";
import Test from "./pages/Test";

import history from "./utils/history";

const Layout = React.lazy(() => import("@/pages/Layout"));
const Login = React.lazy(() => import("@/pages/Login"));

export default function App() {
  return (
    <Router history={history}>
      <React.Suspense fallback={<div>...加载中...</div>}>
        <Switch>
          <Redirect from="/" to="/layout" exact />
          <Route component={Layout} path="/layout" />
          <Route component={Login} path="/login" />

          <Route path="/search/result" component={Result} />
          <Route path="/search" component={Search} />
          <Route path="/article/:id" component={Article} />
          <Route path="/profile/edit" component={ProfileEdit} />
          <Route path="/profile/feedback" component={ProfileFeedback} />
          <Route path="/profile/chat" component={Chat} />
          <Route path="/test" component={Test} />
          <Route component={NotFound} />
        </Switch>
      </React.Suspense>
    </Router>
  );
}
